package sys.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import sys.entity.PageResult;
import sys.entity.Person;
import sys.entity.QueryPageBean;
import sys.entity.Result;
import sys.service.PersonService;



/**
 * @author 秉性哥
 * @createTime 2022/9/20 15:48
 * @description
 */
@CrossOrigin(allowedHeaders = "*")
@RequestMapping("person")
@RestController
public class PersonController {

    @Autowired
    private  PersonService personService;


    /**
     *@description 分页查询
     *@author  秉性哥
     *@params Integer pageIndex
     *@return  com.github.pagehelper.PageInfo
     *@createTime  2022/9/20
     */
    @RequestMapping("findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){
        return personService.findPage(queryPageBean);
    }


    /**
     *@description 添加人员
     *@author  秉性哥
     *@params  person
     *@return  Result
     *@createTime  2022/9/20
     */
    @RequestMapping("add")
    public Result add(@RequestBody Person person){
         personService.add(person);

        return new Result(false,"添加成功");
    }


    /**
     *@description 修改人员
     *@author  秉性哥
     *@params  person
     *@return  Result
     *@createTime  2022/9/20
     */
    @RequestMapping("edit")
    public Result edit(@RequestBody Person person){
        personService.edit(person);
        return new Result(false,"修改成功");
    }

    /**
     *@description 删除人员
     *@author  秉性哥
     *@params  id
     *@return  Result
     *@createTime  2022/9/20
     */
    @RequestMapping("del")
    public Result del(Integer id){
        personService.del(id);
        return new Result(false,"删除成功");
    }

    /**
     *@description 批量删除
     *@author  秉性哥
     *@params ids
     *@return  sys.entity.Result
     *@createTime  2022/9/21
     */
    @RequestMapping("dels")
    public Result dels(Integer[] ids){
        personService.dels(ids);
        return new Result(false,"删除成功");
    }
}
